package com.mdd.front.controller;


import com.mdd.common.core.PageResult;
import com.mdd.front.service.category.IGoodsCategoryService;
import com.mdd.front.validate.PageParam;
import com.mdd.front.vo.category.GoodsCategoryListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 服务分类管理
 */
@Api(tags = "服务分类管理")
@RestController
@RequestMapping("api/category")
public class GoodsCategoryController {

    @Resource
    IGoodsCategoryService iGoodsCategoryService;

    /**
     * 获取一级父类服务分类
     *
     * @return Object
     */
    @ApiOperation(value = "服务分类管理 - 获取一级父类服务分类")
    @GetMapping("/commonList")
    public List<GoodsCategoryListVo> pid(@RequestParam(value = "pid",required = false) Long pid) {
        return iGoodsCategoryService.listPid(pid);
    }

    /**
     * 服务分类列表
     *
     * @param pageParam 分页参数
     * @param params    搜索参数
     * @return Object
     */
    @ApiOperation(value = "服务分类管理 - 分页列表")
    @GetMapping("/list")
    public PageResult<GoodsCategoryListVo> list(@Validated PageParam pageParam,
                                                @RequestParam Map<String, String> params) {
        return iGoodsCategoryService.list(pageParam, params);
    }

}
